define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	$scope.form.father_id=params.father_id;
	$(".xueqi").hide();
	$scope.getYear = function() {
		httpService.post(app.urls.prop_selectYears, {}, function (data) {
			if ("0000" === data.code) {
				$scope.yearList = data.data;
			} else {
				alert(data.msg);
			}
		})
	}

	$scope.showProp = function(){
		$scope.form.real_value = "";
		$scope.form.prop_value = "";
		if($scope.form.prop_key == "STU_YEAR"){
			$(".xuenian").show();
			$(".xueqi").hide();
			$scope.getYear();
		}else{
			$(".xuenian").hide();
			$(".xueqi").show();
			$scope.yearList = [{"name":"第一学期","value":"1"},{"name":"第二学期","value":"2"}]
		}
	}

	$scope.getName = function(){
		if($scope.form.prop_key == "STU_YEAR"){
			$scope.form.prop_value = $scope.form.real_value+"学年";
		}else{
			if($scope.form.real_value == "1"){
				$scope.form.prop_value = "第一学期";
			}else{
				$scope.form.prop_value = "第二学期";
			}
		}
	}

	httpService.postpage(app.urls.prop_select,{"prop_pk":params.id},function(data){
		if("0000" === data.code){
			if(data.data[0].prop_key == "STU_YEAR"){
				$(".xuenian").show();
				$(".xueqi").hide();
				$scope.getYear();
			}else{
				$(".xuenian").hide();
				$(".xueqi").show();
				$scope.yearList = [{"name":"第一学期","value":"1"},{"name":"第二学期","value":"2"}]
			}
			$scope.$apply();
			$scope.form = data.data[0];
			$scope.form.real_value +="";
		}else{
			alert(data.msg);
		}
	});
	$scope.saveForm = function(){
		if($scope.formCheck()) {

			if($scope.form.status == "0"){
				httpService.post(app.urls.prop_updateStatus,{"prop_key":$scope.form.prop_key},function(data){
					if("0000" === data.code){
						eventBusService.publish("content.page.reload", data);
						eventBusService.publish("modal.page.close", {});
					}else{
						alert(data.msg);
					}
				});
			}

			if($scope.form.prop_key == "STU_YEAR"){
				$scope.form.prop_remark = "学年";
			}else{
				$scope.form.prop_remark = "学期";
			}
			console.log($scope.form)
			httpService.post(app.urls.prop_update,$scope.form,function(data){
				if("0000" === data.code){
					eventBusService.publish("content.page.reload", data);
					eventBusService.publish("modal.page.close", {});
				}else{
					alert(data.msg);
				}
			});
		}
	}
}}});